﻿////////////////////////////////////////////////////////////////////////
//Autor: Gabriel Tame Borao  - gabrieltame@yahoo.es 
//Fecha: 2010/09/15 01:26
//Solucion: GTameReport.sln
//Proyecto: GTameReport
//Fichero: QueryType.cs
//
//	Copyright (C) 2010  Gabriel Tame Borao (GTB)
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
namespace GTameReport
{
    using Rdl;
    using System;
    using System.Collections;

    public class QueryType
    {
        private string _CommandText;
        private QueryTypeCommandType _CommandType;
        private string _DataSourceName;
        private GTameReport.QueryParametersType _QueryParameters;
        private uint? _Timeout = null;

        public Rdl.QueryType Write()
        {
            Rdl.QueryType type = new Rdl.QueryType();
            ArrayList list = new ArrayList();
            ArrayList list2 = new ArrayList();
            if (this._CommandText != null)
            {
                list.Add(this._CommandText);
                list2.Add(ItemsChoiceType2.CommandText);
            }
            list.Add(this._CommandType);
            list2.Add(ItemsChoiceType2.CommandType);
            if (this._DataSourceName != null)
            {
                list.Add(this._DataSourceName);
                list2.Add(ItemsChoiceType2.DataSourceName);
            }
            if (this._QueryParameters != null)
            {
                list.Add(this._QueryParameters.Write());
                list2.Add(ItemsChoiceType2.QueryParameters);
            }
            if (this._Timeout.HasValue)
            {
                list.Add(this._Timeout);
                list2.Add(ItemsChoiceType2.Timeout);
            }
            type.Items = list.ToArray();
            type.ItemsElementName = (ItemsChoiceType2[]) list2.ToArray(typeof(ItemsChoiceType2));
            list2 = null;
            list = null;
            return type;
        }

        public string CommandText
        {
            get
            {
                return this._CommandText;
            }
            set
            {
                this._CommandText = value;
            }
        }

        public QueryTypeCommandType CommandType
        {
            get
            {
                return this._CommandType;
            }
            set
            {
                this._CommandType = value;
            }
        }

        public string DataSourceName
        {
            get
            {
                return this._DataSourceName;
            }
            set
            {
                this._DataSourceName = value;
            }
        }

        public GTameReport.QueryParametersType QueryParameters
        {
            get
            {
                if (this._QueryParameters == null)
                {
                    this._QueryParameters = new GTameReport.QueryParametersType();
                }
                return this._QueryParameters;
            }
            set
            {
                this._QueryParameters = value;
            }
        }

        public uint? Timeout
        {
            get
            {
                return this._Timeout;
            }
            set
            {
                this._Timeout = value;
            }
        }
    }
}

